﻿using System.Windows.Forms;
using DirectMobile.Controls;
using Microsoft.WindowsMobile.DirectX.Direct3D;

namespace DirectMobile
{
	/// <summary>
	/// Provides static methods and properties to manage a DirectMobileApplication
	/// </summary>
	public sealed class DMApplication
	{
		private static DMApplication _currentApplication;

		private DMApplication() { }

		/// <summary>
		/// Gets the current instance of the DMApplication
		/// </summary>
		public static DMApplication Current
		{
			get
			{
				return _currentApplication;
			}
		}

		/// <summary>
		/// Gets the DirectX Device associated with this application.
		/// </summary>
		internal Device Device { get; set; }
       

		public void ShowFrame(Frame frame)
		{
			
		}

		/// <summary>
		/// Begins running a standard application loop on the current thread. A host window is created.
		/// </summary>
		public static void Run()
		{
			var mainForm = new HostForm();
			if (!mainForm.InitializeGraphics())
				Exit();
			_currentApplication = new DMApplication();
			Current.Device = mainForm.Device;
			Application.Run(mainForm);
		}

		/// <summary>
		/// Terminates the current application.
		/// </summary>
		public static void Exit()
		{
			Application.Exit();
		}

		/// <summary>
		/// Processes all Windows messages currently in the message queue.
		/// </summary>
		public static void DoEVents()
		{
			Application.DoEvents();
		}
	}
}
